﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace Project_V1
{
    public partial class FrmDebug : Form
    {
        public FrmDebug()
        {
            InitializeComponent();
            this.timer1.Interval = 200;
            this.Load += FrmDebug_Load;
        }

        private void FrmDebug_Load(object sender, EventArgs e)
        {
            this.timer1.Enabled = true;
            txt_SetPos1.ReadOnly = true;
        }

        //双击事件,将值传给参数修改界面,弹出界面
        private void ModifyTxt_UserControlClick(object sender, EventArgs e)
        {
            if (sender is TextBoxControl)
            {
                TextBoxControl item = (TextBoxControl)sender;

                string InitialValue = item.ActualValue;//将控件读取的ActualValue赋值给参数修改界面的Label显示

                string Variable = string.Empty;
                if (item.Tag != null)//由控件Tag的值得到变量名
                {
                    Variable =  item.Tag.ToString();//拼接变量名
                }
                FrmParaModify objFrm = new FrmParaModify(InitialValue, Variable);
                objFrm.ShowDialog();
            }
            else if (sender is TextBox)
            {
                TextBox item = (TextBox)sender;

                string InitialValue = item.Text;//将控件读取的ActualValue赋值给参数修改界面的Label显示

                string Variable = string.Empty;
                if (item.Tag != null)//由控件Tag的值得到变量名
                {
                    Variable = item.Tag.ToString();//拼接变量名
                }
                FrmParaModify objFrm = new FrmParaModify(InitialValue, Variable);
                objFrm.ShowDialog();
            }


        }










        private void timer1_Tick(object sender, EventArgs e)
        {
            foreach (Control ct in this.Controls)
            {

                if (ct is TextBoxControl && ct.Tag != null && ct.Tag.ToString().IndexOf(".") != -1)
                {
                    if (CommonMethods.CurrentValue != null && CommonMethods.CurrentValue.ContainsKey(ct.Tag.ToString()))
                    {
        
                        ((TextBoxControl)ct).ActualValue = CommonMethods.CurrentValue[ct.Tag.ToString()];
                    }
                }

                if (ct is TextBox && ct.Tag != null && ct.Tag.ToString().IndexOf(".") != -1)
                {
                    if (CommonMethods.CurrentValue != null && CommonMethods.CurrentValue.ContainsKey(ct.Tag.ToString()))
                    {
                        ct.Text = CommonMethods.CurrentValue[ct.Tag.ToString()];
                    }
                }
                if (ct is Button && ct.Tag != null && ct.Tag.ToString() != "" && ct.Tag.ToString().IndexOf(".") != -1)
                {
                    try
                    {
                
                       // if (ct.Tag.ToString() == "_03_HMI.btManualPower1")
                        { 
                            if (CommonMethods.CurrentValue[ct.Tag.ToString()] == "True" && CommonMethods.CurrentValue.ContainsKey(ct.Tag.ToString()))
                            {
                                ct.BackColor = Color.FromArgb(60, 179, 113);
                            }
                            else
                            {
                                ct.BackColor = Color.FromArgb(255, 255, 255);
                            }

                        }
                       // }

 
                    }
                    catch
                    {
                        ct.BackColor = Color.FromArgb(255, 255, 255);
                    }
                }


                if (ct.Name.ToString().ToLower().IndexOf("circle") != -1 && ct.Tag.ToString().IndexOf(".") != -1)
                {
                    if (ct.Tag.ToString() == "_03_HMI.Enabled2")
                    {

                        if (CommonMethods.CurrentValue[ct.Tag.ToString()] == "True" && CommonMethods.CurrentValue.ContainsKey(ct.Tag.ToString()))
                        {
                            ct.BackColor = Color.LimeGreen;
                        }
                        else
                        {
                            ct.BackColor = Color.Olive;
                        }
                    }
                    if (ct.Tag.ToString() == "_03_HMI.Error2")
                    {

                        if (CommonMethods.CurrentValue[ct.Tag.ToString()] == "True" && CommonMethods.CurrentValue.ContainsKey(ct.Tag.ToString()))
                        {
                            ct.BackColor = Color.Red;   //Color.FromArgb(60, 179, 113);
                        }
                        else
                        {
                            ct.BackColor = Color.Olive;
                        }
                    }

                }

 


 
            }
        }

        private void btn_Enable1_Click(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2JOGMinus"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2JOGMinus", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2JOGMinus"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2JOGMinus", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void btn_Reset1_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2HOME", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_Reset1_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2HOME", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogForward1_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogF1", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }
        private void btn_JogForward1_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogF1", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }
        private void btn_JogBackward1_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogB1", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }
        private void btn_JogBackward1_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogB1", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_Enable2_Click(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.btManualPower1"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.btManualPower1", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.btManualPower1"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.btManualPower1", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void btn_Reset2_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btReset1", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_Reset2_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btReset1", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogForward2_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogF2", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogForward2_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogF2", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogBackward2_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogB2", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogBackward2_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogB2", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_Debug_Click(object sender, EventArgs e)
        {
            Beckhoff_PLC.IsWriting = true;
            if (CommonMethods.CurrentValue["_03_HMI.btDebug"] == "False")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btDebug", true);
            }
            if (CommonMethods.CurrentValue["_03_HMI.btDebug"] == "True")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btDebug", false);
            }
            Beckhoff_PLC.IsWriting = false;
        }

        private void btn_YV1_Click(object sender, EventArgs e)
        {
            Beckhoff_PLC.IsWriting = true;
            if (CommonMethods.CurrentValue["_03_HMI.btEnableVacuoValve"] == "False")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btEnableVacuoValve", true);
            }
            if (CommonMethods.CurrentValue["_03_HMI.btEnableVacuoValve"] == "True")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btEnableVacuoValve", false);
            }
            Beckhoff_PLC.IsWriting = false;
        }

        private void btn_YV2_Click(object sender, EventArgs e)
        {
            Beckhoff_PLC.IsWriting = true;
            if (CommonMethods.CurrentValue["_03_HMI.btDisableVacuoValve"] == "False")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btDisableVacuoValve", true);
            }
            if (CommonMethods.CurrentValue["_03_HMI.btDisableVacuoValve"] == "True")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btDisableVacuoValve", false);
            }
            Beckhoff_PLC.IsWriting = false;
        }

        private void btn_YV3_Click(object sender, EventArgs e)
        {
            Beckhoff_PLC.IsWriting = true;
            if (CommonMethods.CurrentValue["_03_HMI.btPrePressureExtendValve"] == "False")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btPrePressureExtendValve", true);
            }
            if (CommonMethods.CurrentValue["_03_HMI.btPrePressureExtendValve"] == "True")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btPrePressureExtendValve", false);
            }
            Beckhoff_PLC.IsWriting = false;
        }

        private void btn_YV4_Click(object sender, EventArgs e)
        {
            Beckhoff_PLC.IsWriting = true;
            if (CommonMethods.CurrentValue["_03_HMI.btPrePressureRetractValve"] == "False")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btPrePressureRetractValve", true);
            }
            if (CommonMethods.CurrentValue["_03_HMI.btPrePressureRetractValve"] == "True")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btPrePressureRetractValve", false);
            }
            Beckhoff_PLC.IsWriting = false;
        }
        private void btn_YV5_Click(object sender, EventArgs e)
        {
            Beckhoff_PLC.IsWriting = true;
            if (CommonMethods.CurrentValue["_03_HMI.btCachePlacePushRivetValve"] == "False")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btCachePlacePushRivetValve", true);
            }
            if (CommonMethods.CurrentValue["_03_HMI.btCachePlacePushRivetValve"] == "True")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btCachePlacePushRivetValve", false);
            }
            Beckhoff_PLC.IsWriting = false;
        }
        private void btn_ClearCounter_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btCounterClear", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_ClearCounter_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btCounterClear", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btFSR", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btFSR", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_btStop_Click(object sender, EventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btSSFR", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_btFeedingTest1_Click(object sender, EventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btSSFR", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void FrmDebug_FormClosed(object sender, FormClosedEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btSSFR", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogForward1_Click(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2JOGPlus"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2JOGPlus", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2JOGPlus"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2JOGPlus", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void btn_JogBackward1_Click(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2PoStart"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2PoStart", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2PoStart"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2PoStart", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void btn_JogForward2_Click(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.btManualJogF1"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogF1", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.btManualJogF1"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogF1", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void btn_JogBackward2_Click(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.btManualJogB1"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogB1", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.btManualJogB1"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogB1", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void btn_YV6_Click(object sender, EventArgs e)
        {
            Beckhoff_PLC.IsWriting = true;
            if (CommonMethods.CurrentValue["_03_HMI.btClampValve"] == "False")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btClampValve", true);
            }
            if (CommonMethods.CurrentValue["_03_HMI.btClampValve"] == "True")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btClampValve", false);
            }
            Beckhoff_PLC.IsWriting = false;
        }

        private void btn_YV7_Click(object sender, EventArgs e)
        {
            Beckhoff_PLC.IsWriting = true;
            if (CommonMethods.CurrentValue["_03_HMI.btCachePlaceBlowRivetValve"] == "False")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btCachePlaceBlowRivetValve", true);
            }
            if (CommonMethods.CurrentValue["_03_HMI.btCachePlaceBlowRivetValve"] == "True")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btCachePlaceBlowRivetValve", false);
            }
            Beckhoff_PLC.IsWriting = false;
        }

        private void btn_YV8_Click(object sender, EventArgs e)
        {
            Beckhoff_PLC.IsWriting = true;
            if (CommonMethods.CurrentValue["_03_HMI.btGunHeadBlowRivetValve"] == "False")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btGunHeadBlowRivetValve", true);
            }
            if (CommonMethods.CurrentValue["_03_HMI.btGunHeadBlowRivetValve"] == "True")
            {
                Beckhoff_PLC.WriteVariable("_03_HMI.btGunHeadBlowRivetValve", false);
            }
            Beckhoff_PLC.IsWriting = false;
        }

        private void FrmDebug_Load_1(object sender, EventArgs e)
        {

        }

        private void btn_Reset1_Click(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2HOME"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2HOME", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2HOME"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2HOME", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void button2_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btCounterClear", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button2_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btCounterClear", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btAbsExecute", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button1_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btAbsExecute", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button3_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btHome", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button3_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btHome", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void timer2_Tick(object sender, EventArgs e)
        {

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2ForceStart"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2ForceStart", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2ForceStart"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2ForceStart", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2STOP"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2STOP", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2STOP"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2STOP", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //Beckhoff_PLC.IsWriting = true;
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2Reset"] == "False")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2Reset", true);
            //}
            //if (CommonMethods.CurrentValue["_03_HMI.MotorDebug_Axis2Reset"] == "True")
            //{
            //    Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2Reset", false);
            //}
            //Beckhoff_PLC.IsWriting = false;
        }

        private void btn_Enable1_MouseDown(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2JOGMinus", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_Enable1_MouseUp(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2JOGMinus", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogForward1_MouseDown_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2JOGPlus", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogForward1_MouseUp_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2JOGPlus", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogBackward1_MouseDown_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2PoStart", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogBackward1_MouseUp_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2PoStart", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button1_MouseDown_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2ForceStart", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button1_MouseUp_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2ForceStart", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button2_MouseDown_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2STOP", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button2_MouseUp_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2STOP", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button3_MouseDown_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2Reset", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void button3_MouseUp_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.MotorDebug_Axis2Reset", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogForward2_MouseDown_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogF1", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogForward2_MouseUp_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogF1", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogBackward2_MouseDown_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogB1", true);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }

        private void btn_JogBackward2_MouseUp_1(object sender, MouseEventArgs e)
        {
            bool btrig = true;
            if (btrig)
            {
                Beckhoff_PLC.IsWriting = true;
                Beckhoff_PLC.WriteVariable("_03_HMI.btManualJogB1", false);
                Beckhoff_PLC.IsWriting = false;
            }
            btrig = false;
        }
    }
}
